﻿using System;
using System.Windows;
using Microsoft.Research.DynamicDataDisplay;
using Microsoft.Research.DynamicDataDisplay.ViewportRestrictions;

namespace Labthink.PCSoft.UniversalHost4.UserControls
{
    /// <summary>
    /// 设置坐标轴范围
    /// </summary>
    internal class ViewportAxesRangeRestriction : IViewportRestriction
    {
        public DisplayRange XRange;
        public DisplayRange YRange;

        public event EventHandler Changed;

        public Rect Apply(Rect oldVisible, Rect newVisible, Viewport2D viewport)
        {
            if (XRange != null)
            {
                newVisible.X = XRange.Start;
                newVisible.Width = XRange.End - XRange.Start;
            }

            if (YRange != null)
            {
                newVisible.Y = YRange.Start;
                newVisible.Height = YRange.End - YRange.Start;
            }
            return newVisible;
        }
    }
}